<!-- 微社区 瀑布流组件 点击进入帖子详情页 -->
<template>
  <div>
    <Waterfall :list="list" :breakpoints="breakpoints" backgroundColor="#f5f5f5">
      <template #item="{ item }">
        <div class="li" :class="{ 'no-click': nowClick }" @click="jumpDetails(item.id)" :key="item.id">
          <div class="top" :class="{ 'text-bg': !item.has_many_image[0] }">
            <img v-if="item.has_many_image[0]" :src="item.has_many_image[0].url" alt="" />
            <div class="mic-content" v-if="!item.has_many_image[0]"><p v-html="item.contents"></p></div>
          </div>
          <div class="bottom">
            <div class="title">{{ item.title }}</div>
            <div class="content">
              <div class="headmessage" v-if="item.has_one_stick_user">
                <div class="left">
                  <img :src="item.has_one_stick_user.avatar" alt="" />
                </div>
                <div class="name">{{ item.has_one_stick_user.nickname }}</div>
              </div>
              <div class="thumbup">
                <div class="right">
                  <i :class="!item.is_praised ? 'iconfont icon-dianzan' : 'iconfont icon-zb_like'" style="font-size:0.8125rem;"></i>
                </div>
                <div class="num">{{ item.praise_num || "赞" }}</div>
              </div>
            </div>
          </div>
          <div v-if="nowClick" class="shenhe">
            <i class="iconfont icon-shenhe"></i>
            <span style="margin-top: 0.4688rem;">待审核</span>
          </div>
        </div>
      </template>
    </Waterfall>
    <van-empty v-if="fun.isTextEmpty(list)" image="search" :description="showLoading ? '抱歉，暂无数据' : '加载中...'" />
    <div class="load" v-if="!showLoading || imgLoading">
      <div class="loader">
        <div class="horizontal">
          <div class="circlesup">
            <div class="circle"></div>
            <div class="circle"></div>
            <div class="circle"></div>
            <div class="circle"></div>
            <div class="circle"></div>
          </div>
        </div>
      </div>
    </div>
    <div v-if="isDiy && !fun.isTextEmpty(list)">
      <div style="width: 100%; height: 40px; line-height: 40px; text-align: center;" v-if="isLoadMore && showLoading && !imgLoading" @click="getMoreData">{{ $i18n.t("加载更多") }}</div>
    </div>
  </div>
</template>

<script>
import { Waterfall } from "vue-waterfall-plugin";
import "vue-waterfall-plugin/dist/style.css";

export default {
  props: ["list", "showLoading", "datas", "isDiy", "isLoadMore", "id", "nowClick", "isclick"],
  data() {
    return {
      imgLoading: false, //图片是否加载完成
      isclicknow: false,

      breakpoints: {
        1200: {
          //当屏幕宽度小于等于1200
          rowPerView: 4
        },
        800: {
          //当屏幕宽度小于等于800
          rowPerView: 3
        },
        500: {
          //当屏幕宽度小于等于500
          rowPerView: 2
        }
      }
    };
  },
  components: { Waterfall },
  computed: {},
  mounted() {
    this.imgLoading = false;
    this.$emit("loadMore", true);
  },
  activated() {
    this.imgLoading = false;
  },
  methods: {
    getMoreData() {
      this.$emit("getMore", true);
    },
    jumpDetails(stick_id) {
      if (this.nowClick === true) {
        return;
      }
      this.$router.push(
        this.fun.getUrl("microCommentDetails", {
          stickId: stick_id
        })
      );
    }
  },
  watch: {
    list: function(newVal, oldVal) {
      this.$emit("loadMore", true);
    }
  }
};
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
#Waterfalls_flow {
  .icon-zb_like {
    color: var(--themeBaseColor);
    font-size: 1rem !important;
  }

  .shenhe {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 11;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #fff;
    transform: translate(-50%, -50%);
  }
  .no-click {
    position: relative;
    &::after {
      content: "";
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      opacity: 0.45;
      z-index: 10;
      background: #000;
    }
  }

  .load {
    .loader {
      text-align: center;
      /* disable selection and cursor changes */
      -webkit-touch-callout: none;
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
      cursor: default;
      z-index: 9999;
    }

    /* Set for the second layer horizontal position */
    .horizontal {
      -webkit-transform: rotate(0deg);
      -moz-transform: rotate(0deg);
      -ms-transform: rotate(0deg);
      -o-transform: rotate(0deg);
      transform: rotate(0deg);
    }

    /* The next two classes do mirror for animation */

    /* Create a container for our circles, rotate it 45 degrees and set animation */
    .circle {
      // position: fixed;
      // width: 3rem;
      // height: 3rem;
      -webkit-transform: rotate(45deg);
      -moz-transform: rotate(45deg);
      -ms-transform: rotate(45deg);
      -o-transform: rotate(45deg);
      transform: rotate(45deg);
      -webkit-animation: orbit 2s infinite;
      -moz-animation: orbit 2s infinite;
      -ms-animation: orbit 2s infinite;
      -o-animation: orbit 2s infinite;
      animation: orbit 2s infinite;
      z-index: 5;
    }

    /* Style's of our circles */
    .circle::after {
      content: "";
      position: fixed;
      width: 15px;
      height: 15px;
      -webkit-border-radius: 100%;
      -moz-border-radius: 100%;
      -ms-border-radius: 100%;
      -o-border-radius: 100%;
      border-radius: 100%;
      background: var(--themeLoadingColor); /* Pick a color 1 */
    }

    .circle:nth-child(2) {
      -webkit-animation-delay: 100ms;
      -moz-animation-delay: 100ms;
      -ms-animation-delay: 100ms;
      -o-animation-delay: 100ms;
      animation-delay: 100ms;
      z-index: 4;
    }

    .circle:nth-child(2)::after {
      background: var(--themeLoadingColor); /* Pick a color 2 */
      -webkit-transform: scale(0.8, 0.8);
      -moz-transform: scale(0.8, 0.8);
      -ms-transform: scale(0.8, 0.8);
      -o-transform: scale(0.8, 0.8);
      transform: scale(0.8, 0.8);
      opacity: 0.7;
    }

    .circle:nth-child(3) {
      -webkit-animation-delay: 225ms;
      -moz-animation-delay: 225ms;
      -ms-animation-delay: 225ms;
      -o-animation-delay: 225ms;
      animation-delay: 225ms;
      z-index: 3;
    }

    .circle:nth-child(3)::after {
      background: var(--themeLoadingColor); /* Pick a color 3 */
      -webkit-transform: scale(0.6, 0.6);
      -moz-transform: scale(0.6, 0.6);
      -ms-transform: scale(0.6, 0.6);
      -o-transform: scale(0.6, 0.6);
      transform: scale(0.6, 0.6);
      opacity: 0.6;
    }

    .circle:nth-child(4) {
      -webkit-animation-delay: 350ms;
      -moz-animation-delay: 350ms;
      -ms-animation-delay: 350ms;
      -o-animation-delay: 350ms;
      animation-delay: 350ms;
      z-index: 2;
    }

    .circle:nth-child(4)::after {
      background: var(--themeLoadingColor); /* Pick a color 4 */
      -webkit-transform: scale(0.4, 0.4);
      -moz-transform: scale(0.4, 0.4);
      -ms-transform: scale(0.4, 0.4);
      -o-transform: scale(0.4, 0.4);
      transform: scale(0.4, 0.4);
      opacity: 0.5;
    }

    .circle:nth-child(5) {
      -webkit-animation-delay: 475ms;
      -moz-animation-delay: 475ms;
      -ms-animation-delay: 475ms;
      -o-animation-delay: 475ms;
      animation-delay: 475ms;
      z-index: 1;
    }

    .circle:nth-child(5)::after {
      background: var(--themeLoadingColor); /* Pick a color 5 */
      -webkit-transform: scale(0.2, 0.2);
      -moz-transform: scale(0.2, 0.2);
      -ms-transform: scale(0.2, 0.2);
      -o-transform: scale(0.2, 0.2);
      transform: scale(0.2, 0.2);
      opacity: 0.4;
    }

    /* Animation keys */
    @-webkit-keyframes orbit {
      0% {
        -webkit-transform: rotate(45deg);
      }

      5% {
        -webkit-transform: rotate(45deg);
        -webkit-animation-timing-function: ease-out;
      }

      70% {
        -webkit-transform: rotate(405deg);
        -webkit-animation-timing-function: ease-in;
      }

      100% {
        -webkit-transform: rotate(405deg);
      }
    }

    @keyframes orbit {
      0% {
        transform: rotate(45deg);
      }

      5% {
        transform: rotate(45deg);
        animation-timing-function: ease-out;
      }

      70% {
        transform: rotate(405deg);
        animation-timing-function: ease-in;
      }

      100% {
        transform: rotate(405deg);
      }
    }
  }
}

.li {
  border-radius: 0.75rem;
  width: 100%;
  background-color: #fff;
  padding-bottom: 0.69rem;
  margin-bottom: 0.375rem;
  overflow: hidden;

  .top {
    // display: flex;
    margin: 0;
    padding: 0;

    img {
      max-height: 14.375rem;
      width: 100%;
      overflow: hidden;
      margin: 0;
      display: block;
    }

    .mic-content {
      margin: 0.375rem;
      padding: 0.75rem;
      background-color: #f6f6f6;
      font-size: 0.8125rem;
      color: #3b3b4a;
      line-height: 18px;
      min-height: 48px;
      border-radius: 0.5rem;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 6;
    }
  }

  .bottom {
    padding: 0 0.625rem;

    .title {
      font-weight: 600;
      padding-top: 0.375rem;
      font-size: 0.875rem;
      line-height: 1rem;
      display: -webkit-box;
      text-overflow: ellipsis;
      overflow: hidden;
      color: #00001c;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
      text-align: left;
      margin-bottom: 0.625rem;
    }

    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      align-items: center;
      .headmessage {
        display: flex;
        align-items: center;
        .left {
          width: 1.13rem;
          height: 1.13rem;

          img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
          }
        }

        .name {
          width: 4rem;
          margin-left: 0.1875rem;
          height: 1.13rem;
          line-height: 1.13rem;
          text-align: left;
          color: #808080;
          font-size: 0.6875rem;
          overflow: hidden; /* 超出部分隐藏 */
          text-overflow: ellipsis; /* 超出部分显示省略号 */
          white-space: nowrap; /* 规定段落中的文本不进行换行 */
        }
      }

      .thumbup {
        display: flex;
        align-items: center;
        .right {
          margin-right: 0.1563rem;
        }

        .num {
          // min-width: 2rem;
          // min-width: 2rem;
          max-width: 8rem;
          text-align: left;
          color: #3b3b4a;
          font-size: 0.75rem;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
      }
    }
  }
}
</style>
